Naming Conventions — GDScript

Skill codes on this page

Code Level Skill
C711 1–2 identifies naming conventions
C721 3–4 applies naming to variables
C731 5–6 applies naming to interface controls
C741 7–8 applies naming to code structures
C751 9–10 applies naming to ALL solution elements

Definition. A naming convention is an agreed set of rules by which to name source code elements such as variables, functions, classes, methods and objects. (Camel case: each word after the first starts with a capital. Snake case: words joined with underscores. Hungarian notation: the name encodes purpose and type.)

C7-1 is one ladder: each level applies the convention to more kinds of element. In the validation Part B naming audit you state your convention, then fix non-compliant names live.

The Godot house convention

Element Convention Example
Variables snake_case, descriptive pairs_to_find, is_concession
Constants UPPER_SNAKE_CASE DAILY_CAP
Functions action-verb snake_case calculate_fare()
Classes (class_name) PascalCase MykiCard
Nodes / interface controls PascalCase, purpose + control type AddButton, BalanceLabel
Signals snake_case, past tense fare_calculated
Files and scenes snake_case team_row.gd, card.tscn

This is the convention every studied project uses — and the one Godot's own style guide recommends.

C711 — Identify your convention

Level 1–2 is stating the rules, in internal documentation, before applying them:

# C711 — naming conventions in this project:
# variables and functions snake_case; constants UPPER_SNAKE_CASE;
# classes and nodes PascalCase; signals snake_case, past tense

Earns the tick: the convention written down where the marker can find it. In the naming audit, this is the sentence you open with.

C721 — Variables

Bad names hide meaning; the fix is descriptive snake_case:

# ✗ before — earns no C721: the names hide the meaning
var b := 20.00      # what is b?
var f := 5.30       # what is f?
var balance: float = 20.00   # C721 — descriptive snake_case
var fare: float = 5.30       # C721
var is_concession := false   # C721 — booleans read as yes/no questions

In the studied projects: pairs_to_find, is_busy, flip_back_delay (tile-matching-game); points_for_win, team_name (club-ladder). Every boolean starts is_ — the name reads as the question the code asks.

Magic numbers are a naming problem too. A bare 0.5 says nothing; a named constant says everything:

# ✗ before — magic number, earns no C721
fare = FARE_TABLE[zone] * 0.5              # what is 0.5?
const CONCESSION_DISCOUNT := 0.5           # C721 — the rule now has a name
fare = FARE_TABLE[zone] * CONCESSION_DISCOUNT

Earns the tick: no single-letter names (a loop i is fine), booleans as is_/has_ questions, magic numbers replaced by named constants.

C731 — Interface controls

Name every Control node purpose + control type, in PascalCase:

NameField    (LineEdit)     ← what it holds + what it is
AddButton    (Button)
TitleLabel   (Label)
WarningLabel (Label)

Those four are club-ladder's real scene — the name tells you what the control does before you click it. The anti-pattern is Godot's defaults left in place: Button1, LineEdit, Label2.

# C731 — controls named purpose + type, so the code reads in English
%AddButton.pressed.connect(_on_add_pressed)
name_field.text = ""

Earns the tick: every control in the picked feature's scene named this way — the audit will open your scene tree and look.

C741 — Code structures

Functions get action verbs; classes get PascalCase nouns:

# ✗ before — earns no C741: the name says nothing
func f(x):            # what does f do?
func calculate_fare(zone: int) -> float:   # C741 — verb says what it does
class_name MykiCard   # C741 — PascalCase noun, a clear concept

In the studied projects: load_csv(), mark_matched(), start_new_game() (tile-matching-game); class_name Team, Season, Ladder (club-ladder) — every function name is a verb phrase, every class a noun.

C751 — All solution elements

Level 9–10 extends the convention to everything that has a name: signals, scenes, files, autoloads — consistently, throughout.

# club-ladder — the convention on every element kind
signal result_recorded(team: Team, result: String)   # C751 — signal: past tense
signal remove_requested(team: Team)                  # C751
# files: team_row.gd, season.gd — snake_case
# scenes: main.tscn, team_row.tscn — snake_case

Earns the tick: open any file in the project and the convention holds — variables, constants, functions, classes, nodes, signals, files. One inconsistent corner (studentName beside student_id) drops you back.

Check Your Understanding

  1. What convention does a Godot node (interface control) use, and what two things should its name say?
Answer

PascalCase, saying purpose + control type — AddButton, BalanceLabel.

  1. Why is fare * 0.5 a naming problem, and what is the fix?
Answer

0.5 is a magic number — its meaning is invisible. Replace it with a named constant: CONCESSION_DISCOUNT := 0.5.

  1. What separates C751 from C741?
Answer

C741 covers code structures (functions and classes). C751 extends the convention to every named element — signals, scenes, files, autoloads — with no inconsistent corners anywhere.